#ifdef AUDIOPACKAGE
#include "BindAudio.hpp"

using namespace luabind;
namespace bind
{
	namespace SFML
	{
		namespace audio
		{
			void BListener(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Listener>("Listener")
							.def("GetGlobalVolume", &sf::ListenerGetGlobalVolume)
							.def("SetGlobalVolume", &sf::ListenerSetGlobalVolume)
							.def("GetPosition", &sf::ListenerGetPosition)
							.def("GetDirection", &sf::ListenerGetDirection)
							.def("SetPosition", (void(*)(sf::Listener&, float, float, float))&sf::ListenerSetPosition)
							.def("SetPosition", (void(*)(sf::Listener&, const sf::Vector3f&))&sf::ListenerSetPosition)
							.def("SetDirection", (void(*)(sf::Listener&, float, float, float))&sf::ListenerSetDirection)
							.def("SetDirection", (void(*)(sf::Listener&, const sf::Vector3f&))&sf::ListenerSetDirection)
					];
			}

			void BMusic(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Music, bases<sf::SoundStream> >("Music")
							.enum_("Status")
								[
									value("Stopped", sf::Music::Stopped),
									value("Paused", sf::Music::Paused),
									value("Playing", sf::Music::Playing)
								]
							.def(constructor<>())
							.def("OpenFromFile", &sf::Music::OpenFromFile)
							.def("OpenFromMemory", &sf::Music::OpenFromMemory)
							.def("GetDuration", &sf::Music::GetDuration)
							.def("Play", &sf::Music::Play)
							.def("Pause", &sf::Music::Pause)
							.def("Stop", &sf::Music::Stop)
							.def("GetChannelsCount", &sf::Music::GetChannelsCount)
							.def("GetSampleRate", &sf::Music::GetSampleRate)
							.def("GetStatus", &sf::Music::GetStatus)
							.def("SetPlayingOffset", &sf::Music::SetPlayingOffset)
							.def("GetPlayingOffset", &sf::Music::GetPlayingOffset)
							.def("SetLoop", &sf::Music::SetLoop)
							.def("GetLoop", &sf::Music::GetLoop)
							.def("SetPitch", &sf::Music::SetPitch)
							.def("SetVolume", &sf::Music::SetVolume)
							.def("SetPosition", (void(sf::Music::*)(float, float, float))&sf::Music::SetPosition)
							.def("SetPosition", (void(sf::Music::*)(const sf::Vector3f&))&sf::Music::SetPosition)
							.def("SetRelativeToListener", &sf::Music::SetRelativeToListener)
							.def("SetMinDistance", &sf::Music::SetMinDistance)
							.def("SetAttenuation", &sf::Music::SetAttenuation)
							.def("GetPitch", &sf::Music::GetPitch)
							.def("GetVolume", &sf::Music::GetVolume)
							.def("GetPosition", &sf::Music::GetPosition)
							.def("IsRelativeToListener", &sf::Music::IsRelativeToListener)
							.def("GetMinDistance", &sf::Music::GetMinDistance)
							.def("GetAttenuation", &sf::Music::GetAttenuation)
					];
			}
				
			void BSound(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Sound, bases<sf::SoundSource> >("Sound")
							.enum_("Status")
								[
									value("Stopped", sf::Sound::Stopped),
									value("Paused", sf::Sound::Paused),
									value("Playing", sf::Sound::Playing)
								]
							.def(constructor<>())
							.def(constructor<const sf::SoundBuffer&, bool, float, float, const sf::Vector3f&>())
							.def(constructor<const sf::Sound&>())
							.def("Play", &sf::Sound::Play)
							.def("Pause", &sf::Sound::Pause)
							.def("Stop", &sf::Sound::Stop)
							.def("SetBuffer", &sf::Sound::SetBuffer)
							.def("SetLoop", &sf::Sound::SetLoop)
							.def("SetPlayingOffset", &sf::Sound::SetPlayingOffset)
							.def("GetBuffer", &sf::Sound::GetBuffer)
							.def("GetLoop", &sf::Sound::GetLoop)
							.def("GetPlayingOffset", &sf::Sound::GetPlayingOffset)
							.def("GetStatus", &sf::Sound::GetStatus)
							.def("ResetBuffer", &sf::Sound::ResetBuffer)
							.def("SetPitch", &sf::Sound::SetPitch)
							.def("SetVolume", &sf::Sound::SetVolume)
							.def("SetPosition", (void(sf::Sound::*)(float, float, float))&sf::Sound::SetPosition)
							.def("SetPosition", (void(sf::Sound::*)(const sf::Vector3f&))&sf::Sound::SetPosition)
							.def("SetRelativeToListener", &sf::Sound::SetRelativeToListener)
							.def("SetMinDistance", &sf::Sound::SetMinDistance)
							.def("SetAttenuation", &sf::Sound::SetAttenuation)
							.def("GetPitch", &sf::Sound::GetPitch)
							.def("GetVolume", &sf::Sound::GetVolume)
							.def("GetPosition", &sf::Sound::GetPosition)
							.def("IsRelativeToListener", &sf::Sound::IsRelativeToListener)
							.def("GetMinDistance", &sf::Sound::GetMinDistance)
							.def("GetAttenuation", &sf::Sound::GetAttenuation)
					];
			//AudioDevice.hpp
			//AudioResource.hpp
			//SoundFile.hpp
			//SoundFileDefault.hpp
			//SoundFileOgg.hpp
			}
				
			void BSoundBuffer(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::SoundBuffer>("SoundBuffer")
							.def(constructor<>())
							.def(constructor<const sf::SoundBuffer&>())
							.def("LoadFromFile", &sf::SoundBuffer::LoadFromFile)
							.def("LoadFromMemory", &sf::SoundBuffer::LoadFromMemory)
							.def("LoadFromSamples", &sf::SoundBuffer::LoadFromSamples)
							.def("SaveToFile", &sf::SoundBuffer::SaveToFile)
							.def("GetSamples", &sf::SoundBuffer::GetSamples)
							.def("GetSamplesCount", &sf::SoundBuffer::GetSamplesCount)
							.def("GetSamplesRate", &sf::SoundBuffer::GetSampleRate)
							.def("GetChannelsCount", &sf::SoundBuffer::GetChannelsCount)
							.def("GetDuration", &sf::SoundBuffer::GetDuration)
					];
			}
				
			void BSoundBufferRecorder(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::SoundBufferRecorder, bases<sf::SoundRecorder> >("SoundBufferRecorder")
							.def("GetBuffer", &sf::SoundBufferRecorder::GetBuffer)
							.def("Start", &sf::SoundBufferRecorder::Start)
							.def("Stop", &sf::SoundBufferRecorder::Stop)
							.def("GetSampleRate", &sf::SoundBufferRecorder::GetSampleRate)
							.def("IsAvailable", &sf::SoundBufferRecorder::IsAvailable)
					];
			}
				
			void BSoundRecorder(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::SoundRecorder>("SoundRecorder")
							.def("Start", &sf::SoundRecorder::Start)
							.def("Stop", &sf::SoundRecorder::Stop)
							.def("GetSampleRate", &sf::SoundRecorder::GetSampleRate)
							.def("IsAvailable", &sf::SoundRecorder::IsAvailable)
					];
			}

			void BSoundSource(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::SoundSource>("SoundSource")
							.def(constructor<const sf::SoundSource&>())
							.def("SetPitch", &sf::SoundSource::SetPitch)
							.def("SetVolume", &sf::SoundSource::SetVolume)
							.def("SetPosition", (void(sf::SoundSource::*)(float, float, float))&sf::SoundSource::SetPosition)
							.def("SetPosition", (void(sf::SoundSource::*)(const sf::Vector3f&))&sf::SoundSource::SetPosition)
							.def("SetRelativeToListener", &sf::SoundSource::SetRelativeToListener)
							.def("SetMinDistance", &sf::SoundSource::SetMinDistance)
							.def("SetAttenuation", &sf::SoundSource::SetAttenuation)
							.def("GetPitch", &sf::SoundSource::GetPitch)
							.def("GetVolume", &sf::SoundSource::GetVolume)
							.def("GetPosition", &sf::SoundSource::GetPosition)
							.def("IsRelativeToListener", &sf::SoundSource::IsRelativeToListener)
							.def("GetMinDistance", &sf::SoundSource::GetMinDistance)
							.def("GetAttenuation", &sf::SoundSource::GetAttenuation)
					];

				object status = newtable(lua);
				status["Stopped"] = sf::SoundSource::Status::Stopped;
				status["Paused"] = sf::SoundSource::Status::Paused;
				status["Playing"] = sf::SoundSource::Status::Playing;
				globals(lua)[ns.c_str()]["SoundSource"]["Status"] = status;
			}
				
			void BSoundStream(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::SoundStream, bases<sf::SoundSource> >("SoundStream")
							.enum_("Status")
								[
									value("Stopped", sf::SoundStream::Stopped),
									value("Paused", sf::SoundStream::Paused),
									value("Playing", sf::SoundStream::Playing)
								]
							.def("Play", &sf::SoundStream::Play)
							.def("Pause", &sf::SoundStream::Pause)
							.def("Stop", &sf::SoundStream::Stop)
							.def("GetChannelsCount", &sf::SoundStream::GetChannelsCount)
							.def("GetSampleRate", &sf::SoundStream::GetSampleRate)
							.def("GetStatus", &sf::SoundStream::GetStatus)
							.def("SetPlayingOffset", &sf::SoundStream::SetPlayingOffset)
							.def("GetPlayingOffset", &sf::SoundStream::GetPlayingOffset)
							.def("SetLoop", &sf::SoundStream::SetLoop)
							.def("GetLoop", &sf::SoundStream::GetLoop)
							.def("SetPitch", &sf::SoundStream::SetPitch)
							.def("SetVolume", &sf::SoundStream::SetVolume)
							.def("SetPosition", (void(sf::SoundStream::*)(float, float, float))&sf::SoundStream::SetPosition)
							.def("SetPosition", (void(sf::SoundStream::*)(const sf::Vector3f&))&sf::SoundStream::SetPosition)
							.def("SetRelativeToListener", &sf::SoundStream::SetRelativeToListener)
							.def("SetMinDistance", &sf::SoundStream::SetMinDistance)
							.def("SetAttenuation", &sf::SoundStream::SetAttenuation)
							.def("GetPitch", &sf::SoundStream::GetPitch)
							.def("GetVolume", &sf::SoundStream::GetVolume)
							.def("GetPosition", &sf::SoundStream::GetPosition)
							.def("IsRelativeToListener", &sf::SoundStream::IsRelativeToListener)
							.def("GetMinDistance", &sf::SoundStream::GetMinDistance)
							.def("GetAttenuation", &sf::SoundStream::GetAttenuation),
						class_<sf::SoundStream::Chunk>("SoundStreamChunk")
							.def_readwrite("Samples", &sf::SoundStream::Chunk::Samples)
							.def_readwrite("NbSamples", &sf::SoundStream::Chunk::NbSamples)
					];
			}
				
			//OpenAL
				
			void Bind(lua_State* lua, const std::string& ns)
			{
				open(lua);
				BListener(lua, ns);
				BMusic(lua, ns);
				BSoundSource(lua, ns);
				BSoundStream(lua, ns);
				BSound(lua, ns);
				BSoundBuffer(lua, ns);
				BSoundRecorder(lua, ns);
				BSoundBufferRecorder(lua, ns);
			}
		}
	}
}

#endif //AUDIOPACKAGE